Skip to content

fix: cap Pexels b-roll at 1080p to prevent Lambda disk overflow#621

Merged
codercatdev merged 1 commit intodevfrom
fix/pexels-resolution-cap
Mar 5, 2026
Merged

fix: cap Pexels b-roll at 1080p to prevent Lambda disk overflow#621
codercatdev merged 1 commit intodevfrom
fix/pexels-resolution-cap

Conversation

@codercatdev
Copy link
Contributor

Fix: Cap Pexels B-Roll at 1080p

Root cause: selectBestFile() in pexels.ts was falling back to the highest resolution file when no exact 1080p match existed. This selected 4K UHD files (4096×2160, typically 100-500MB) that exceeded Lambda's 2GB disk limit, causing all 91 render chunks to fail with disk space errors.

Fix: Changed the fallback logic in selectBestFile():

Before After
No 1080p match → pick highest resolution No 1080p match → pick highest at or below 1080p
Could select 4K UHD (4096×2160, ~500MB) Caps at 1080p (~20-50MB)
N/A If ALL files exceed 1080p → pick smallest available

One file changed: lib/services/pexels.ts — only the selectBestFile() function.

The selection priority is now:

  1. Exact 1920×1080 match (landscape) or 1080×1920 (portrait)
  2. File with width matching target (1920 or 1080)
  3. Highest resolution at or below target width
  4. If all files exceed target → smallest available (not largest)

No other files changed. The getBRollForScene() and searchVideos() APIs are unchanged.

selectBestFile() was falling back to the highest resolution file when
no exact 1080p match existed. This selected 4K UHD files (4096×2160,
100-500MB) that exceeded Lambda's 2GB disk limit, causing all render
chunks to fail.

Now prefers the highest resolution at or below 1080p. If all files
exceed 1080p, picks the smallest available instead of the largest.
@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
codingcat-dev Ignored Ignored Mar 5, 2026 2:42pm

@codercatdev codercatdev merged commit fb363f5 into dev Mar 5, 2026
2 of 3 checks passed
codercatdev added a commit that referenced this pull request Mar 5, 2026
fix: cap Pexels b-roll at 1080p — Lambda disk overflow fix
@codercatdev codercatdev deleted the fix/pexels-resolution-cap branch March 5, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant